package com.itheima.udp1;

import java.net.DatagramPacket;
import java.net.DatagramSocket;

/**
 * @author Anomaly
 * @date 2023/2/11 13:51
 */
public class Server {
    public static void main(String[] args) throws Exception {
        System.out.println("==============服务端启动=================");
        DatagramSocket socket = new DatagramSocket(8888);
        byte[] buffer = new byte[64 * 1024];
        DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
        socket.receive(packet);
        System.out.println("服务端收到消息：" + new String(buffer,0,packet.getLength()));
        System.out.println(packet.getSocketAddress());
        System.out.println(packet.getAddress());
        System.out.println(packet.getPort());
        socket.close();
    }
}
